<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>vue-boot 用户管理</title>
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <link rel="stylesheet" href="../static/plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="../static/plugins/adminLTE/css/AdminLTE.css">
    <link rel="stylesheet" href="../static/plugins/adminLTE/css/skins/_all-skins.min.css">
    <link rel="stylesheet" href="../static/css/style.css">
    <link rel="stylesheet" href="../static/plugins/pageination/zpageNav.css">
    <script src="../static/plugins/jQuery/jquery-2.2.3.min.js"></script>
    <script src="../static/plugins/bootstrap/js/bootstrap.min.js"></script>

</head>

<body class="hold-transition skin-red sidebar-mini">

<div id="app">
    <div class="box-header with-border" style="height: 64.5px;line-height: 54px;">
        <h3 class="box-title">登录日志</h3>
    </div>
    <div class="box-body">
        <!-- 数据表格 -->
        <div class="table-box">
            <!--工具栏-->
            <div class="pull-left">
                <div class="form-group form-inline">
                    <div class="btn-group">
                        <button type="button" class="btn btn-default" title="删除" @click="deleteLogs()"><i
                                class="fa fa-trash-o"></i> 删除
                        </button>
                        <button type="button" class="btn btn-default" title="刷新" onclick="window.location.reload();"><i
                                class="fa fa-refresh"></i> 刷新
                        </button>
                        <button type="button" class="btn btn-success fileinput-button"  title="导出" @click="outPutExcel()" ><i
                                class="fa fa-refresh" ></i> 导出Excel
                        </button>



                    </div>
                    <div class="box-tools pull-right">
                        <div class="has-feedback" style="margin-left: 750px; font-size: 16px">
                            登录时间查询: <input type="text" v-model="key" class="form-control">
                            <input class="btn btn-default" type="button" @click="pageHandler(1)" value="查询">
                        </div>
                    </div>
                </div>
            </div>
            <div class="box-tools pull-right">
                <div class="has-feedback"></div>
            </div>
            <!--数据列表-->
            <table id="dataList" class="table table-bordered table-striped table-hover dataTable">
                <thead>
                <tr>
                    <th class="" style="padding-right:0px">
                        <input id="selall" type="checkbox" class="icheckbox_square-blue">
                    </th>
                    <th class="sorting_asc">id</th>
                    <th class="sorting_asc">登陆日期</th>
                    <th class="sorting_asc">登录用户</th>
                    <th class="sorting_asc">流水号</th>
                </tr>
                </thead>
                <tbody>
                <tr v-for="LoginLogItem in LoginLogList">
                    <td><input type="checkbox" @click="deleteSelect($event,LoginLogItem.id)"></td>
                    <td>{{LoginLogItem.id}}</td>
                    <td>{{LoginLogItem.logindate}}</td>
                    <td>{{LoginLogItem.loginuser}}</td>
                    <td>{{LoginLogItem.serialid}}</td>
                </tr>

                </tbody>

            </table>

        </div>
    </div>
    <!--分页-->
    <zpagenav v-bind:page="page" v-bind:page-size="pageSize" v-bind:total="total"
              v-bind:max-page="maxPage" v-on:pagehandler="pageHandler">
    </zpagenav>

</div>
</body>


<script src="../static/plugins/vue/vuejs-2.5.16.js"></script>
<script src="../static/plugins/vue/axios-0.18.0.js"></script>
<script src="../static/plugins/vue/qs.js"></script>
<script src="../static/plugins/pageination/zpageNav.js"></script>
<script>

    new Vue({
        el: "#app",
        data: {
            page: 1,//当前页
            pageSize: 5,//每页显示数据
            total: 0,//记录总数
            key: '', //查询关键字
            LoginLogList: [],
            selectIds:[],
        },
        methods: {
            pageHandler: function (page) {
                var _this = this;
                this.page = page;
                axios.post("/LoginLog/Search?page=" + page + "&size=" + this.pageSize + "&key=" + this.key)
                    .then(function (response) {
                        //取服务端响应的结果
                        _this.LoginLogList = response.data.data.records;
                        _this.total = response.data.data.total;
                        _this.pageSize = response.data.data.size;
                        console.log(response);
                    }).catch(function (reason) {
                    console.log(reason);
                })
            },
            deleteSelect: function (event, id) {
                if (event.target.checked) {
                    this.selectIds.push(id);
                } else {
                    var ids = this.selectIds.indexOf(id);
                    this.selectId.splice(ids, 1);
                }
            },
            deleteLogs: function () {
                var _this = this;
                axios.post("/LoginLog/deleteLogs",Qs.stringify({ids: _this.selectIds}, {indices: false}))
                    .then(function (response) {
                        if (response.data.success) {
                            _this.pageHandler(_this.page);
                            _this.selectIds = [];
                            window.alert(response.data.msg);
                        } else {
                            window.alert(response.data.msg);
                        }
                    }).catch(function (result) {
                    console.log(result);

                });
            },



            outPutExcel: function () {
                window.location.href = "/outPutLoginLogExcel";
                window.alert("导出Excel成功!");

            }
             },
        created: function () {
            this.pageHandler(1);
        }
    })

</script>


</html>